package com.atguigu.stgy.admin.controller;

import com.atguigu.stgy.model.entity.CityInfo;
import com.atguigu.stgy.admin.service.impl.CityInfoServiceImpl;
import com.atguigu.stgy.model.result.R;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * (city_info)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/admin/region/city")
public class CityInfoController {
    /**
     * 服务对象
     */
    @Resource
    private CityInfoServiceImpl cityInfoServiceImpl;


    @RequestMapping("listByProvinceId")
    public R<List<CityInfo>> city(@RequestParam("id") Long provinceId){

        List<CityInfo> cityInfos = cityInfoServiceImpl.list(Wrappers.lambdaQuery(CityInfo.class)
                .eq(CityInfo::getProvinceId,provinceId));
        return R.ok(cityInfos);

    }
}